<?php
namespace app\admin\controller;

use app\Request;
use app\admin\model\admin\AdminAuth;
use think\facade\Db;


class Index extends AuthController
{

    protected function initialize()
    {
        parent::initialize();
    }

    public function index ()
    {
        $this->assign("adminInfo",$this->adminInfo);
        $this->assign("menu",AdminAuth::getMenu(0,$this->auth));

        return $this->fetch();
    }
    public function main ()
    {
        // Db::query("truncate table h_user");
        // Db::query("truncate table h_wechat_user");
        // Db::query("truncate table h_system_group");
        // Db::query("truncate table h_system_group_data");
        // Db::query("truncate table h_attachment");
        // Db::query("truncate table h_attachment_category");
        // Db::query("truncate table h_admin_log");
        // Db::query("alter table h_admin_auth AUTO_INCREMENT=21");
        // Db::query("alter table h_system_config AUTO_INCREMENT=17");
        // Db::query("alter table h_system_config_tab AUTO_INCREMENT=3");
        return $this->fetch();
    }

    /**
     * @param Request $request
     * @return
     * @throws \Psr\SimpleCache\InvalidArgumentException
     */
    public function clearCache(Request $request)
    {
        $adminPath = config("cache.runtime")."/admin/";
        $indexPath = config("cache.runtime")."/index/";
        $apiPath = config("cache.runtime")."/api/";
        if (removeCache($adminPath) && removeCache($indexPath) && removeCache($apiPath)) return app("json")->success("操作成功");
        return app("json")->fail("操作失败");
    }


}
